<template>
	<view class="yk_screen">
		<swiper class="yk_swiper" :interval="3000" :duration="1000" @change="changeSwiper" circular autoplay>
			<swiper-item v-for="(item,index) in swiperArray" :key="index" :class="cur==index?'cur':''"
				@click="clickItem(index)">
				<view class="yk_item">
					<image :src="item.img" mode="aspectFill"></image>
				</view>
			</swiper-item>
		</swiper>
		<view class="yk_icon">
			<image src="@/static/logo.png" mode=""></image>
			<view>上滑探索更多</view>
		</view>
		<view class="yk_ul">
			<block v-for="(item,index) in swiperArray" :key="index">
				<view class="yk_li" :class="cur==index?'act':''"></view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			swiperArray: {
				type: Array,
				default () {
					return [];
				}
			}
		},
		data() {
			return {
				cur: 0
			}
		},
		methods: {
			changeSwiper(e) {
				this.cur = e.detail.current;
			},
			clickItem(index) {
				let _index = index + 1;
				uni.showToast({
					title: '您点击了第' + _index + '个'
				})
			}
		}
	}
</script>

<style lang="scss">
	.yk_screen {
		position: relative;
		width: 100%;
		height: 100vh;

		.yk_swiper {
			width: 100%;
			height: 100vh;

			.yk_item {
				position: absolute;
				height: 100vh;

				image {
					width: 100vw;
					height: 100vh;
				}
			}
		}

		.yk_ul {
			z-index: 9999;
			width: 100%;
			height: 36rpx;
			position: absolute;
			z-index: 999;
			bottom: 24rpx;
			display: flex;
			align-items: center;
			border-radius: 20rpx;
			justify-content: center;

			.yk_li {
				background: rgba(255, 255, 255, 0.6);
				width: 80rpx;
				height: 6rpx;
				position: relative;

				&:nth-child(1n) {
					border-radius: 6rpx 0 0 6rpx;
				}

				&:last-child {
					border-radius: 0 6rpx 6rpx 0;
				}
			}

			.yk_li.act {
				height: 12rpx;
				background: #fff;
				border-radius: 0;
			}
		}

		.yk_icon {
			position: absolute;
			z-index: 999;
			text-align: center;
			bottom: 80rpx;
			left: 50%;
			transform: translate(-50%, 0);
			animation: upDown 2s linear infinite;

			view {
				color: #000;
				font-size: 24rpx;
				margin-top: 12rpx;
			}

			image {
				width: 32rpx;
				height: 32rpx;
			}
		}
	}

	@keyframes upDown {
		0% {
			bottom: 80rpx;
		}

		25% {
			bottom: 90rpx;
		}

		50% {
			bottom: 100rpx;
		}

		75% {
			bottom: 90rpx;
		}

		100% {
			bottom: 80rpx;
		}
	}
</style>
